<template>
  <div class="content">
    <el-form
      ref="form"
      :model="form"
    >
      <div class="search">
        <el-form-item
          label="单元"
          class="label"
        >
          <el-input
            v-model="form.name"
            class="input"
            placeholder="请输入单元号"
          />
        </el-form-item>
        <el-form-item
          label="门牌"
          class="label"
        >
          <el-select
            placeholder="请输入门牌号"
            class="input"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            size="mini"
            @click="onSubmit"
          >
            查询
          </el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table
      ref="singleTable"
      :data="tableData"
      :header-cell-style="{background: '#EBECF0',height:'44px',color:'#000000'}"
      :cell-style="{background: '#ffffff',height:'44px',color:'#000000'}"
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        type="index"
        :index="indexMethod"
        width="100"
      />
      <el-table-column
        property="community"
        label="所属小区"

      />
      <el-table-column
        property="door"

        label="单元-门牌"
      />
      <el-table-column
        property="time"
        label="登记时间"
      />
      <el-table-column
        property="applyer"
        label="房主"
      />
      <el-table-column
        property="reviewer"
        label="审核人"
      />
      <el-table-column
        property="address"
        label="操作"
        width="100"
      >
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleClick(scope.row)"
          >
            查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        :current-page.sync="page"
        background
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
      />
    </div>

    <el-dialog
      title
      :visible.sync="dialogFormVisible"
      width="60%"
    >
      <div class="dialog_content">
        <div class="dialog_title">
          房屋信息
        </div>

        <el-form
          ref="form"
          :inline="true"
          :model="detail"
        >
          <el-row :gutter="20">
            <el-col :span="10">
              <el-form-item
                label="所属小区"
                class="label"
              >
                <el-input
                  v-model="detail.community"
                  class="input"
                />
              </el-form-item>
            </el-col>
            <el-col
              :span="10"
              :offset="4"
            >
              <el-form-item
                label="单元-门牌"
                class="label"
              >
                <el-input
                  v-model="detail.door"
                  class="input"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="10">
              <el-form-item
                label="登记时间"
                class="label"
              >
                <el-input
                  v-model="detail.time"
                  class="input"
                />
              </el-form-item>
            </el-col>
            <el-col
              :span="10"
              :offset="4"
            >
              <el-form-item
                label="房主"
                class="label"
              >
                <el-input
                  v-model="detail.applyer"
                  class="input"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import ImgDialog from "@/components/Imgdialog";

export default {
  name: "Dashboard",
  components: {
    ImgDialog
  },
  data() {
    return {
      form: {},
      tableData: [
        {
          name: "张扬阳",
          sex: "男",
          community: "新丰苑三期",
          door: "1-301",
          address: "江苏-无锡",
          time: "2020-10-23 12:23:12",
          applyer: "王浩",
          reviewer: "周华东"
        },
        {
          name: "张扬阳",
          sex: "男",
          community: "新丰苑三期",
          door: "1-301",
          address: "江苏-无锡",
          time: "2020-10-23 12:23:12",
          applyer: "王浩",
          reviewer: "周华东"
        }
      ],
      total: 100,
      page: 10,
      pageSize: 10,
      dialogFormVisible: false,
      detail: {}
    };
  },
  computed: {
    ...mapGetters(["communityId"]),
    indexMethod(index) {
      return (this.page - 1) * 10 + index + 1;
    }
  },
  watch: {
    communityId(newVal, oldVal) {
      console.log("changed");
    }
  },
  created() {},
  methods: {
    handleCurrentChange(val) {
      this.page = val;
    },
    handleClick(row) {
      this.detail = JSON.parse(JSON.stringify(row));
      this.dialogFormVisible = true;
    }
  }
};
</script>
<style lang="scss" scoped>
.content {
  background: #ffffff;
  padding: 25px;
  padding-bottom: 100px;
  min-height: 800px;
  position: relative;
  .search {
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #dcdee3;
    margin-bottom: 30px;
  }
  .input {
    width: 346px;
  }
 .label{
    margin-right: 20px;
    color: #666666;
    font-size: 14px;
  }
  .pagination {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 50px;
  }
  .img {
    width: 50px;
    height: 34px;
  }
}

</style>
<style>
.input .el-input__inner {
  height: 28px !important;
}
</style>
